# Maintainer: Lukas Fleischer <lfleischer@archlinux.org>
# Contributor: dorphell <dorphell@archlinux.org>
# Contributor: Dan McGee <dan@archlinux.org>

pkgname=cvs
pkgver=1.11.23
pkgrel=11
pkgdesc="Concurrent Versions System - a source control system"
arch=(i686 x86_64)
url="http://cvs.nongnu.org/"
license=('GPL')
depends=('krb5' 'zlib')
makedepends=('vim')
optdepends=('openssh: for using cvs over ssh'
            'inetutils: for using cvs over rsh')
source=(ftp://ftp.gnu.org/non-gnu/cvs/source/stable/${pkgver}/${pkgname}-${pkgver}.tar.bz2
        cvs-1.11.19-abortabort.patch
        cvs-1.11.19-comp.patch
        cvs-1.11.19-extzlib.patch
        cvs-1.11.19-logmsg.patch
        cvs-1.11.19-netbsd-tag.patch
        cvs-1.11.19-tagname.patch
        cvs-1.11.19-tmp.patch
        cvs-1.11.21-diff-kk.patch
        cvs-1.11.21-diff.patch
        cvs-1.11.21-sort.patch
        cvs-1.11.23-cve-2010-3846.patch
        cvs-1.11.23-cvspass.patch
        cvs-1.11.23-doc-Add-mandatory-argument-to-sp.patch
        cvs-1.11.23-getline64.patch
        cvs-1.11.23-make_make_check_sanity_testing_verbose.patch
        cvs-1.11.23-Pass-compilation-with-Wformat-security.patch
        cvs-1.11.23-remove_undefined_date_from_cvs_1_header.patch
		cvs-1.11.23-sanity.patch)
sha256sums=('400f51b59d85116e79b844f2d5dbbad4759442a789b401a94aa5052c3d7a4aa9'
            'a63bd4d696d4785f3b16146c9a8e57b7f0b2fcb648b9b3b43b138857e28e23f4'
            '973d2c6682e2e4b9b9a80c0aec7dd436a180adbc06c6ed6914c349627cfb9a6e'
            '0587ac3753d1257fa6d22557fa077178ee1ec004178c0a0348720e8171b1e942'
            'f97ea853f2c7cc6cc0364e1d0ca148be6229c43327417c32a4b253d74bf9fd76'
            'f8e544879d3ca5589c09f56678cd0a5166b727f65ebb4daceaeb70bd700f5f6b'
            '0cf5fa737444344f76c7b361a60e6736ccff7887b5157fb1b2ddd6bd133cc4e5'
            '1ff4ae9d167f5449fbd1c8ae3b489da73b2806df3b3d8795711deffba7856953'
            'd924459e46ea4fb438d0f71b0d87bd528b132bc53224dbfb588b090633f2fea9'
            '70af9380ea697a9ffcca8b33bd3d591ee53e23da250462dd690fca357600fab6'
            '775feb4094f638bf30a47be5b6e098266879ba6592d15d3694fff9365fb65b2d'
            'c6506d0a5efc7b0cab6415f26e070ec214fb9781fac8d295506f4d0825431a8f'
            '14a356126159097a5d2d0462547eb2853bf331d8bc7d850be245f751ec17965e'
            '30f68fc13474db4468d22fbdbe771b5f107217cdd2513c058e07de8fe7300d01'
            '9126d7992ace943980ad8a10d5a09aeb6f1eeeb9b921fc796fe31de7b1c220cf'
            '9eeb10fcee6a131210c16978f2eb91fad3e7a8df7fc579bda0ea3a4108c78e1d'
            '54e2ed54d893f14441cf0242493719d8361f54209eefc88b7ac3b9c07ae6625a'
            '887d09d266a796582b046ef36c80792a1b244aea714cd9280f6928cef7dc6698'
            'f661dbd97518b12d63b1cec2f3e6f1ab8219aeddfd1e96e7e505f38ffb04a4b2')

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  unset EDITOR VISUAL

  patch -Np1 < ../cvs-1.11.19-extzlib.patch
  patch -Np1 < ../cvs-1.11.23-getline64.patch
  # CVE-2010-3864, https://www.redhat.com/security/data/cve/CVE-2010-3846.html
  patch -Np1 < ../cvs-1.11.23-cve-2010-3846.patch
  patch -Np1 < ../cvs-1.11.19-abortabort.patch
  patch -Np1 < ../cvs-1.11.19-comp.patch
  patch -Np1 < ../cvs-1.11.19-netbsd-tag.patch
  patch -Np1 < ../cvs-1.11.19-tagname.patch
  patch -Np1 < ../cvs-1.11.19-tmp.patch
  patch -Np1 < ../cvs-1.11.21-diff-kk.patch
  patch -Np1 < ../cvs-1.11.21-diff.patch
  patch -Np1 < ../cvs-1.11.21-sort.patch
  patch -Np1 < ../cvs-1.11.23-cvspass.patch
  patch -Np1 < ../cvs-1.11.19-logmsg.patch
  patch -Np1 < ../cvs-1.11.23-doc-Add-mandatory-argument-to-sp.patch
  patch -Np1 < ../cvs-1.11.23-make_make_check_sanity_testing_verbose.patch
  patch -Np1 < ../cvs-1.11.23-Pass-compilation-with-Wformat-security.patch
  patch -Np1 < ../cvs-1.11.23-remove_undefined_date_from_cvs_1_header.patch
  patch -Np1 < ../cvs-1.11.23-sanity.patch

  sed -i -e 's/AM_CONFIG_HEADER/AC_CONFIG_HEADERS/' configure.in
  find . -name Makefile.am | xargs sed -i -e 's/^INCLUDES/AM_CPPFLAGS/'
  AUTOMAKE='automake --add-missing' autoreconf
  ./configure --prefix=/usr
  make
}

package() {
  cd "${srcdir}/${pkgname}-${pkgver}"

  make DESTDIR="${pkgdir}" install
  rm "${pkgdir}"/usr/share/info/dir
}
